# -*- coding: UTF-8 -*-
#cd /Users/wuchunlong/local/kjwy/python/disk-df

# 生成磁盘使用情况的日志文件
#(env375) $ python disk_log_file.py
# 2022-09-04[08/54/03].log
# Filesystem       Size   Used  Avail Capacity iused      ifree %iused  Mounted on
# /dev/disk1s5s1  466Gi   21Gi   61Gi    26%  553788 4882923132    0%   /
# devfs           187Ki  187Ki    0Bi   100%     646          0  100%   /dev
# /dev/disk1s4    466Gi  1.0Gi   61Gi     2%       2 4883476918    0%   /System/Volumes/VM
# /dev/disk1s2    466Gi  270Mi   61Gi     1%     801 4883476119    0%   /System/Volumes/Preboot
# /dev/disk1s6    466Gi  109Mi   61Gi     1%     394 4883476526    0%   /System/Volumes/Update
# /dev/disk1s1    466Gi  382Gi   61Gi    87% 4704776 4878772144    0%   /System/Volumes/Data
# /dev/disk1s5    466Gi   21Gi   61Gi    26%  553698 4882923222    0%   /System/Volumes/Update/mnt1

import os

# python调用linux命令,获得磁盘信息
#(env375)$ python disk_os_popen.py
#('/dev/disk1s1', '466Gi', '64Gi', '86%')
def disk_info():
	#return  ''.join(os.popen('df -h').readlines())
	items = [i for i in  os.popen('df -h ').readlines()[6].split(' ') if i]
	return items[0],items[1],items[3],items[4]

if __name__ == "__main__":
	print(disk_info())
